import { fetch } from '../../../utils/util';

export class PathParams {
  /** userId */
  userId = undefined;

  [key: string]: any;
}

export type ResponseType = Promise<defs.ResultVO<defs.ListResultVO<defs.Menu>>>;

export const URL = '/api/menu/user/{userId}';

/**
 * @desc 获取指定用户可访问的菜单列表
 */
export function request(
  pathParams: PathParams,
  options?: WechatMiniprogram.RequestOption,
): ResponseType {
  let url = '/api/menu/user/{userId}';

  for (let key in pathParams) {
    url.replace('{' + key + '}', pathParams[key]);
  }

  const fetchOption = Object.assign(
    {
      url: url,
      method: 'GET',
      headers: {
        'Content-Type': 'application/json',
      },
    },
    options,
  );
  return fetch(fetchOption);
}
